package cn.rslee.java.demos.test

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object Filter {
  def main(args: Array[String]): Unit = {
    val sc = new SparkContext(new SparkConf().setAppName("Filter").setMaster("local"));
    val rdd = sc.makeRDD(Array(1, 2, 3, 4, 5, 6,7,6,5,4,3));
    rdd.filter(x => x < 5).foreach(println);
    val r0 = rdd.filter { x => x < 5 };
    println(r0.collect().mkString(","));
    rdd.distinct().foreach(println)
    rdd.map(x=>(x,1)).reduceByKey(_ +_).map(x=>x._1).foreach(println)
  }
}